<template>
  <div style="display: flex; justify-content: space-between">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>文件处理</el-breadcrumb-item>
      <el-breadcrumb-item>excel导入</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- <el-button @click="fn">导入文件</el-button> -->
    <input type="file" @change="fileChange" />
  </div>
</template>

<script lang="ts" setup>
import * as XLSX from "xlsx";

const fileChange = (e: any) => {
  // 不用记
  // console.log(e.target.files[0]);

  const reader = new FileReader();
  reader.readAsBinaryString(e.target.files[0]);

  reader.onload = () => {
    const workbook = XLSX.read(reader.result, { type: "binary" });
    let res = workbook.Sheets["产品信息"];
    res = XLSX.utils.sheet_to_json(res);
    console.log(res);
  };
};
</script>
